﻿var _PageIndex;
var _PageUpCount;
var _Direction;
function LoadingOrderList(tagObjectId) { 
    var _querytext = $("#txtSearch").val();
    if (_querytext == $("#txtSearch").attr("init_value"))
        _querytext = "";

    $.ajax({
        async: true,
        type: "POST",
        url: prependOrgName("/insurance_orderutility.aspx"),
        data: {
            otype: "loadingorderilist",
            page: _PageIndex,
            upcount: _PageUpCount,
            direction: _Direction,
            querytext: _querytext,
            status: $("#selStatus").val()
        },
        beforeSend: function () {
            $("#" + tagObjectId).append("<tr><td colspan=\"7\" style=\"height: 50px; text-align: center;\"><img src=" + prependOrgName("/_imgs/progress.gif") + " style=\"border: 0;\" /></td></tr>");
            $("#" + tagObjectId).html("");
        },
        success: function (data, textStatus) {
            $("#" + tagObjectId).html("");
            $("#" + tagObjectId).append(data);
        }
    });
}
function pagination(page, upcount, direction) {
    _PageIndex = page;
    _PageUpCount = upcount;
    _Direction = direction;
    LoadingOrderList("tbdOrderList");
}
function QueryOrderList() {
    _PageIndex = 1;
    _PageUpCount = 1;
    _Direction = "";
    LoadingOrderList("tbdOrderList");
}
function ValidateUserState() {
    $.ajax({
        type: "POST",
        url: prependOrgName("/insurance_orderutility.aspx"),
        data: { otype: "validateuserstate" },
        async: false,
        success: function (data, textStatus) {
            if (data == "succeeded") {
                return true;
            }
            else {
                return false;
            }
        }
    });
}
function LoadEnumItemsDDL(objectid, _enumkey) {
    $.ajax({
        async: false,
        type: "POST",
        url: prependOrgName("/insurance_orderutility.aspx"),
        data: { otype: "getenumitemsddl", enumkey: _enumkey },
        success: function (data, textStatus) {
            $("#" + objectid).emptySelect().append(data);
        }
    });
}

function LoadEnumItemsDDLBYGroupCode(objectid, _enumkey, _code) {
    $.ajax({
        async: false,
        type: "POST",
        url: prependOrgName("/insurance_orderutility.aspx"),
        data: { otype: "getenumitemsddlbygroupcode", enumkey: _enumkey, groupcode: _code },
        success: function (data, textStatus) {
            $("#" + objectid).emptySelect().append(data);
        }
    });
}

function LoadDDLListByObjectId(objectid, _otype) {
    $.ajax({
        async: false,
        type: "POST",
        url: prependOrgName("/insurance_orderutility.aspx"),
        data: { otype: _otype },
        success: function (data, textStatus) {
            $("#" + objectid).emptySelect().append(data);
        }
    });
}

function LoadDDLListByObjectIdAndCode(objectid, _otype, _code) {
    $.ajax({
        async: false,
        type: "POST",
        url: prependOrgName("/insurance_orderutility.aspx"),
        data: { otype: _otype, groupcode: _code },
        success: function (data, textStatus) {
            $("#" + objectid).emptySelect().append(data);
        }
    });
}
